package world.liuru.poem.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import world.liuru.poem.entity.Consumer;
import world.liuru.poem.service.ConsumerService;

import javax.annotation.Resource;
import java.util.Objects;

@RestController
@RequestMapping("/consumer")

public class LoginController {

    /** 通过 */
    private static final String PASS = "1";
    /** 拒绝 */
    private static final String DENY = "0";

    @Resource
    ConsumerService consumerService;
    @PostMapping("/login")
    public String login(String name,String password){

        Consumer consumer = consumerService.getConsumer(name,password);
        if (Objects.isNull(consumer)){
            return DENY;
        }
        return PASS;
    }

}
